Skip to content

Fix validation logic for dataset upload form#422

Merged
annehaley merged 1 commit into
masterfrom
fix-upload-valid
Jul 22, 2026
Merged

Fix validation logic for dataset upload form#422
annehaley merged 1 commit into
masterfrom
fix-upload-valid

Conversation

@annehaley

Copy link
Copy Markdown
Collaborator

While writing the documentation for dataset upload, I found a bug in the validation logic. The max upload size validation rule never returns undefined; it returns a string error message or true. In the definition of the computed valid variable, we had checked for undefined values. This PR changes that logic to check whether an error message string was returned.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploying geodatalytics with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9542e69
Status: ✅  Deploy successful!
Preview URL: https://8a52f1ef.geodatalytics.pages.dev
Branch Preview URL: https://fix-upload-valid.geodatalytics.pages.dev

View logs

@annehaley
annehaley requested a review from BryonLewis July 20, 2026 16:05

@BryonLewis BryonLewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relatively minor question about using explict true vs not a string check on rule validation.

This kind of brings up something else, would this be cleaner to utilize a v-form with a v-model="isFormValid" and use that variable to disable the submit button and || it with submitting. Then it checks all of the rules in the v-form automatically without needing the computed function combining previous rules?

https://vuetifyjs.com/en/components/forms/#usage

https://vuetifyjs.com/en/components/forms/#validation-state

I would understand not wanting to make a large a change to to this component.

l.name &&
l.files.length &&
fileUploadRules.every((rule) => rule(l.files) === undefined) &&
fileUploadRules.every((rule) => typeof rule(l.files) !== "string") &&

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry again this is minor. I know that your current fileUploadRules is a single rule that returns and error string or a true value.

Should the check be more inline with vuetify to check for explict true (=== true) instead of if the typeof rule(l.files) !== "string"?

https://vuetifyjs.com/en/api/v-validation/#props-rules - the documentation supports true, false, string. So in the future if you have more rules and they return 'false (meaning not valid) they could pass this check.

I do understand that this is inside of a computed function that will ultimately evaluate to either true/false and that it isn't attached to vuetify's :rule directive but wondering if the change would help for consistency.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree that === true is more consistent and readable. Changed in 9542e69

@annehaley

Copy link
Copy Markdown
Collaborator Author

It's true that a v-form can help to consolidate some of the validation logic, but when I tried this out, I couldn't find a clean way to implement the last part of the current valid computed property. We need to ensure that for every layer configuration, (l.frame_method === "single" || l.frame_property).

The frame method and frame property are controlled with v-btn-toggle controls, which do not accept a rules prop. We could create a hidden input control here, but I think that would increase complexity beyond what it's worth.

@BryonLewis
BryonLewis self-requested a review July 22, 2026 17:55

@BryonLewis BryonLewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation about the vbtn-toggle and the interaction with the frame stuff. I didn't think of that when I quickly looked at the component. Everything looks good.

@annehaley
annehaley merged commit 061479b into master Jul 22, 2026
4 checks passed
@annehaley
annehaley deleted the fix-upload-valid branch July 22, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants